package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.THeal;
import com.ruoyi.system.service.ITHealService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * healController
 * 
 * @author SJQ
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/system/heal")
public class THealController extends BaseController
{
    @Autowired
    private ITHealService tHealService;

    /**
     * 查询heal列表
     */
    @PreAuthorize("@ss.hasPermi('system:heal:list')")
    @GetMapping("/list")
    public TableDataInfo list(THeal tHeal)
    {
        startPage();
        List<THeal> list = tHealService.selectTHealList(tHeal);
        return getDataTable(list);
    }

    /**
     * 导出heal列表
     */
    @PreAuthorize("@ss.hasPermi('system:heal:export')")
    @Log(title = "heal", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, THeal tHeal)
    {
        List<THeal> list = tHealService.selectTHealList(tHeal);
        ExcelUtil<THeal> util = new ExcelUtil<THeal>(THeal.class);
        util.exportExcel(response, list, "heal数据");
    }

    /**
     * 获取heal详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:heal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tHealService.selectTHealById(id));
    }

    /**
     * 新增heal
     */
    @PreAuthorize("@ss.hasPermi('system:heal:add')")
    @Log(title = "heal", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody THeal tHeal)
    {
        return toAjax(tHealService.insertTHeal(tHeal));
    }

    /**
     * 修改heal
     */
    @PreAuthorize("@ss.hasPermi('system:heal:edit')")
    @Log(title = "heal", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody THeal tHeal)
    {
        return toAjax(tHealService.updateTHeal(tHeal));
    }

    /**
     * 删除heal
     */
    @PreAuthorize("@ss.hasPermi('system:heal:remove')")
    @Log(title = "heal", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tHealService.deleteTHealByIds(ids));
    }
}
